import type { API } from '@/utils/api';
import service from '@/utils/https';
import type {
	IRaceListParams,
	IRaceListResponseData,
	IResponseType
} from './type';

/**
 * 赛事列表
 */
export const getRaceList = (params: IRaceListParams): Promise<IResponseType<IRaceListResponseData>> => {
	return service({
		url: 'system/rest/race/find-race-list',
		method: 'post',
		data: params,
	})
}

/**
 * 赛事创建 - 上传赛事logo
 * @param params 要传的参数值
 * @returns 返回接口数据
 */
export const postUploadImg = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/file/upload',
		method: 'post',
		headers: {
			'Content-Type': 'multipart/form-data'
		},
		data: params,
	})
}

/**
 * 赛事创建 - 查询赛事详情
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export const getMatchDetail = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/get-race-by-id',
		method: 'get',
		params,
	})
}

/**
 * 赛事创建 - 新增赛事
 * @param params 要传的参数值
 * @returns 返回接口数据
 */
export const postAddMatch = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/save-race',
		method: 'post',
		data: params,
	})
}

/**
 * 赛事创建 - 新增赛事
 * @param params 要传的参数值
 * @returns 返回接口数据
 */
export const postUpdateMatch = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/update-race',
		method: 'post',
		data: params,
	})
}


/**
 * 查询用户当前赛事球队列表
 */
export const getTeamList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/find-race-team-list',
		method: 'get',
		params,
	})
}


/**
 * 球队审核 - 信息查询
 */
export const getRaceTeamRegisterInfo = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/team/get-race-team-register-info',
		method: 'get',
		params,
	})
}


/**
 * 球队审核 - 审核
 */
export const teamAudit = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/team-audit',
		method: 'post',
		data: params,
	})
}

/**
 * 球队审核 - 信息更新
 */
export const teamAuditUpdate = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/team/update-team-player',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 新增赛事阶段
 */
export const saveRace = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/save-race-stage',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 更新赛事阶段
 */
export const updateRace = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/update-race-stage',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 查询赛事阶段
 */
export const getRace = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/get-race-stage',
		method: 'get',
		params,
	})
}

/**
 * 赛程管理 - 新增赛事阶段配置
 */
export const saveRaceConfig = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/save-race-stage-config',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 更新赛事阶段配置
 */
export const updateRaceConfig = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/update-race-stage-config',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 查询赛事阶段配置
 */
export const getRaceConfig = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/get-race-stage-config',
		method: 'get',
		params,
	})
}

/**
 * 赛程管理 - 查询赛事阶段球队分组
 */
export const getRaceGroup = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/find-stage-team-group',
		method: 'get',
		params,
	})
}

/**
 * 赛程管理 - 更新赛事阶段球队分组
 */
export const updateRaceGroup = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/stage/update-stage-team-group',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 查询赛事阶段赛程安排
 */
export const getRaceGroupSchedule = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/schedule/find-race-schedule',
		method: 'get',
		params,
	})
}

/**
 * 赛程管理 - 新增赛事阶段赛程安排
 */
export const saveRaceGroupSchedule = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/schedule/save-race-schedule',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 更新赛事阶段赛程安排
 */
export const updateRaceGroupSchedule = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/schedule/update-race-schedule',
		method: 'post',
		data: params,
	})
}

/**
 * 赛程管理 - 查询赛事阶段配置人员信息
 */
export const getRaceRoleList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/schedule/find-role-list',
		method: 'get',
		params,
	})
}

/**
 * 比赛数据 - 查询比赛数据
 */
export const getRacePlayerData = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/find-race-player-data',
		method: 'get',
		params,
	})
}

/**
 * 比赛数据 - 查询比赛名单
 */
export const getRacePlayerList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/find-race-player-list',
		method: 'get',
		params,
	})
}


/**
 * 数据统计 - 积分榜数据
 */
export const getRaceScoreboard = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-race-scoreboard',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 射手榜数据
 */
export const getRaceScoreTop = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-race-top-scorer',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 红黄榜（球员）
 */
export const getRaceScorePlayer = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-race-player-penalty-board',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 红黄榜（球队）
 */
export const getRaceScoreTeam = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-race-team-penalty-board',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 清空黄牌（球员）
 */
export const postClearCardPlayer = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/clear-team-player-yellow-card',
		method: 'post',
		params,
	})
}

/**
 * 数据统计 - 清空黄牌（球队）
 */
export const postClearCardTeam = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/clear-team-yellow-card',
		method: 'post',
		data: params,
	})
}

/**
 * 数据统计 - 查询赛事阶段和赛事轮次映射关系
 */
export const getRaceStageMapping = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-race-stage-round-mapping',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 查询球队和球员映射关系
 */
export const getRaceTeamMapping = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-team-player-mapping',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 查询红黄牌统计
 */
export const getRacePlayerBoard = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-suspend-race-player-penalty-board',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 查询停赛总榜
 */
export const getRaceSuspendBoard = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-race-suspend-board',
		method: 'get',
		params,
	})
}

/**
 * 数据统计 - 添加停赛球员
 */
export const postSaveTeamPlayer = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/save-suspend-team-player',
		method: 'post',
		data: params,
	})
}

/**
 * 数据统计 - 更新停赛球员
 */
export const postUpdateTeamPlayer = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/update-suspend-team-player',
		method: 'post',
		data: params,
	})
}

/**
 * 数据统计 - 删除停赛球员
 */
export const postDelTeamPlayer = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/delete-suspend-team-player',
		method: 'post',
		params,
	})
}

/**
 * 名单打印列表
 */
export const findRaceScheduleList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/find-race-schedule-form-list',
		method: 'get',
		params,
	})
}


/**
 * 名单打印 - 查询球队首发名单
 */
export const getTeamStartingList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/get-team-starting-list',
		method: 'get',
		params,
	})
}

/**
 * 名单打印 - 保存球队首发名单 
 */
export const saveTeamStartingList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/save-team-starting-list',
		method: 'post',
		data: params,
	})
}

/**
 * 名单打印 - 填报单打印
 */
export const getTeamFile = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/race/data/download-team-form',
		method: 'get',
		params,
	})
}